//显示弹窗

import 'dart:async';

import 'package:flutter/material.dart';

import 'dialog_listener.dart';

showDialogMenu(BuildContext context) {
  showDialog(
      context: context,
      //是否可以点击外部关闭
      barrierDismissible: false,
      builder: (BuildContext context) {
        return WillPopScope(
          //热键返回是否响应
          onWillPop: () async => false,
          child: AlertDialog(
            title: const Text("我是弹窗"),
            content: const Text("我是内容哈哈哈哈哈哈哈哈"),
            actions: [
              TextButton(
                child: const Text("确定"),
                onPressed: () {
                  print("确定----》");
                  Navigator.pop(context, "diaLogClos");
                },
              ),
              TextButton(
                child: const Text("取消"),
                onPressed: () {
                  print("取消----》");
                  Navigator.pop(context);
                },
              ),
            ],
          ).build(context),
        );
      }).then((value) => {print("关闭弹窗----》$value"), Navigator.pop(context)});
}

showDialogDelete(BuildContext context, int p, String content , OnDialogListener listener) {
  showDialog(
      context: context,
      //是否可以点击外部关闭
      barrierDismissible: false,
      builder: (BuildContext context) {
        return WillPopScope(
          //热键返回不是否响应
          onWillPop: () async => false,
          child: AlertDialog(
            title: const Text("删除"),
            content: Text("你确定删除$content"),
            actions: [
              TextButton(
                child: const Text("确定"),
                onPressed: () {
                  Navigator.pop(context);
                  listener.onConfirm();
                },
              ),
              TextButton(
                child: const Text("取消"),
                onPressed: () {
                  Navigator.pop(context);
                  listener.onCancel();
                },
              ),
            ],
          ).build(context),
        );
      });
}
